﻿<%@ Page Language="C#" %>

<%
    CmsDataContext db = new CmsDataContext();
    string keyword = (from aA in db.Article 
                      where aA.ID.Equals(Request.Params["aid"]) 
                      select aA.Keywords).First();

    var arts = (from aA in db.Article
                where aA.Verified != null&&aA.Keywords.Contains(keyword)
                orderby aA.Published descending
                select aA).Take(6);
    if (keyword != "")
    {
        System.Linq.Expressions.Expression<Func<Article, bool>> lmbda = PredicateBuilder<Article>.CreatePredicate(
            new string[] { "Keywords" }, keyword, "aA");
        var p = arts.Where(lmbda);
        if (p.Count() != 0)
        {
            arts = p;
        }
    }
    
    foreach (Article a in arts)
    {%> 
            <li><a href="<%=Toolkit.ApplicationRoot %>/Html/<%=a.Url %>"><%=a.Title.ToString().Length > 11 ? a.Title.ToString().Substring(0, 11) + "..." : a.Title%></a></li>      
    <%}
%>